package com.ymatou.iapi.couponmanage.testcase;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.couponmanage.parameter.BatchInfo;
import com.ymatou.iapi.couponmanage.parameter.CouponValue;
import com.ymatou.iapi.couponmanage.parameter.CreateBagBean;
import com.ymatou.iapi.couponmanage.service.CreateBagCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.database.model.couponbag;
import com.ymttest.database.model.couponbatch;
import com.ymttest.database.model.couponbatchext;
import com.ymttest.database.model.couponsequence;
import com.ymttest.database.model.couponusecondition;
import com.ymttest.database.sqlwapper.couponbagWapper;
import com.ymttest.database.sqlwapper.couponbatchWapper;
import com.ymttest.database.sqlwapper.couponbatchextWapper;
import com.ymttest.database.sqlwapper.couponsequenceWapper;
import com.ymttest.database.sqlwapper.couponuseconditionWapper;
import com.ymttest.utils.EnvSetup;
/**
*创建套券
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_CreateBag{
	private static CreateBagBean createbagBean;
	private static CreateBagCall createbagCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("创建套券");
	}

	@Before
	public void caseUp() {
		createbagBean=new CreateBagBean();
		createbagCall=new CreateBagCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(createbagCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CreateBag_001() {
		Logger.start(true,"创建套券");
		try {
			setDefaultCreatebagBean();
			createbagCall.setData(createbagBean);
			createbagCall.callService();			
			verifyReturn();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CreateBag_002() {
		Logger.start(true,"创建套券-UserType为0：全部用户");
		try {
			setDefaultCreatebagBean();
			createbagBean.setReceiveUserType(0);
			createbagCall.setData(createbagBean);
			createbagCall.callService();			
			verifyReturn();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CreateBag_003() {
		Logger.start(true,"创建套券-UserType为1：新用户");
		try {
			setDefaultCreatebagBean();
			createbagBean.setReceiveUserType(1);
			createbagCall.setData(createbagBean);
			createbagCall.callService();			
			verifyReturn();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CreateBag_004() {
		Logger.start(true,"创建套券-UserType为2：老用户");
		try {
			setDefaultCreatebagBean();
			createbagBean.setReceiveUserType(2);
			createbagCall.setData(createbagBean);
			createbagCall.callService();			
			verifyReturn();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CreateBag_005() {
		Logger.start(true,"创建套券-usePlatformIds下单平台限制：不传为无限制");
		try {
			setDefaultCreatebagBean();
			List<Integer> list = new ArrayList<Integer>();
			createbagBean.setUsePlatformIds(list);
			createbagCall.setData(createbagBean);
			createbagCall.callService();			
			verifyReturn();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CreateBag_006() {
		Logger.start(true,"创建套券-usePlatformIds下单平台限制：PC：1");
		try {
			setDefaultCreatebagBean();
			List<Integer> list = new ArrayList<Integer>();
			list.add(1);
			createbagBean.setUsePlatformIds(list);
			createbagCall.setData(createbagBean);
			createbagCall.callService();			
			verifyReturn();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CreateBag_007() {
		Logger.start(true,"创建套券-usePlatformIds下单平台限制：PC：6");
		try {
			setDefaultCreatebagBean();
			List<Integer> list = new ArrayList<Integer>();
			list.add(6);
			createbagBean.setUsePlatformIds(list);
			createbagCall.setData(createbagBean);
			createbagCall.callService();			
			verifyReturn();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CreateBag_008() {
		Logger.start(true,"创建套券-usePlatformIds下单平台限制：PC：12");
		try {
			setDefaultCreatebagBean();
			List<Integer> list = new ArrayList<Integer>();
			list.add(12);
			createbagBean.setUsePlatformIds(list);
			createbagCall.setData(createbagBean);
			createbagCall.callService();			
			verifyReturn();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CreateBag_009() {
		Logger.start(true,"创建套券-usePlatformIds下单平台限制：APP：3");
		try {
			setDefaultCreatebagBean();
			List<Integer> list = new ArrayList<Integer>();
			list.add(3);
			createbagBean.setUsePlatformIds(list);
			createbagCall.setData(createbagBean);
			createbagCall.callService();			
			verifyReturn();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CreateBag_010() {
		Logger.start(true,"创建套券-usePlatformIds下单平台限制：APP：4");
		try {
			setDefaultCreatebagBean();
			List<Integer> list = new ArrayList<Integer>();
			list.add(4);
			createbagBean.setUsePlatformIds(list);
			createbagCall.setData(createbagBean);
			createbagCall.callService();			
			verifyReturn();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CreateBag_011() {
		Logger.start(true,"创建套券-usePlatformIds下单平台限制：APP：7");
		try {
			setDefaultCreatebagBean();
			List<Integer> list = new ArrayList<Integer>();
			list.add(7);
			createbagBean.setUsePlatformIds(list);
			createbagCall.setData(createbagBean);
			createbagCall.callService();			
			verifyReturn();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CreateBag_012() {
		Logger.start(true,"创建套券-usePlatformIds下单平台限制：APP：8");
		try {
			setDefaultCreatebagBean();
			List<Integer> list = new ArrayList<Integer>();
			list.add(8);
			createbagBean.setUsePlatformIds(list);
			createbagCall.setData(createbagBean);
			createbagCall.callService();			
			verifyReturn();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CreateBag_013() {
		Logger.start(true,"创建套券-usePlatformIds下单平台限制：APP：10");
		try {
			setDefaultCreatebagBean();
			List<Integer> list = new ArrayList<Integer>();
			list.add(10);
			createbagBean.setUsePlatformIds(list);
			createbagCall.setData(createbagBean);
			createbagCall.callService();			
			verifyReturn();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CreateBag_014() {
		Logger.start(true,"创建套券-usePlatformIds下单平台限制：APP：11");
		try {
			setDefaultCreatebagBean();
			List<Integer> list = new ArrayList<Integer>();
			list.add(11);
			createbagBean.setUsePlatformIds(list);
			createbagCall.setData(createbagBean);
			createbagCall.callService();			
			verifyReturn();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CreateBag_015() {
		Logger.start(true,"创建套券-usePlatformIds下单平台限制：WAP：2");
		try {
			setDefaultCreatebagBean();
			List<Integer> list = new ArrayList<Integer>();
			list.add(2);
			createbagBean.setUsePlatformIds(list);
			createbagCall.setData(createbagBean);
			createbagCall.callService();			
			verifyReturn();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CreateBag_016() {
		Logger.start(true,"创建套券-usePlatformIds下单平台限制：WAP：5");
		try {
			setDefaultCreatebagBean();
			List<Integer> list = new ArrayList<Integer>();
			list.add(5);
			createbagBean.setUsePlatformIds(list);
			createbagCall.setData(createbagBean);
			createbagCall.callService();			
			verifyReturn();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CreateBag_017() {
		Logger.start(true,"创建套券-usePlatformIds下单平台限制：WAP：9");
		try {
			setDefaultCreatebagBean();
			List<Integer> list = new ArrayList<Integer>();
			list.add(9);
			createbagBean.setUsePlatformIds(list);
			createbagCall.setData(createbagBean);
			createbagCall.callService();			
			verifyReturn();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CreateBag_018() {
		Logger.start(true,"创建套券-usePlatformIds下单平台限制：PC：1,6,12");
		try {
			setDefaultCreatebagBean();
			List<Integer> list = new ArrayList<Integer>();
			list.add(1);
            list.add(6);
            list.add(12);
			createbagBean.setUsePlatformIds(list);
			createbagCall.setData(createbagBean);
			createbagCall.callService();			
			verifyReturn();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CreateBag_019() {
		Logger.start(true,"创建套券-usePlatformIds下单平台限制：APP：3,4,7,8,10,11");
		try {
			setDefaultCreatebagBean();
			List<Integer> list = new ArrayList<Integer>();
			list.add(3);
            list.add(4);
            list.add(7);
            list.add(8);
            list.add(10);
            list.add(11);
			createbagBean.setUsePlatformIds(list);
			createbagCall.setData(createbagBean);
			createbagCall.callService();			
			verifyReturn();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CreateBag_020() {
		Logger.start(true,"创建套券-usePlatformIds下单平台限制：WAP：2,5,9");
		try {
			setDefaultCreatebagBean();
            List<Integer> list = new ArrayList<Integer>();
            list.add(2);
            list.add(5);
            list.add(9);
			createbagBean.setUsePlatformIds(list);
			createbagCall.setData(createbagBean);
			createbagCall.callService();			
			verifyReturn();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CreateBag_021() {
		Logger.start(true,"创建套券-UsePlatforms下单平台限制：PC、APP、WAP同时存在");
		try {
			setDefaultCreatebagBean();
            List<Integer> list = new ArrayList<Integer>();
            list.add(1);
            list.add(6);
            list.add(3);
            list.add(4);
            list.add(7);
            list.add(8);
            list.add(10);
            list.add(11);
            list.add(2);
            list.add(5);
            list.add(9);
			createbagBean.setUsePlatformIds(list);
			createbagCall.setData(createbagBean);
			createbagCall.callService();			
			verifyReturn();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CreateBag_022() {
		Logger.start(true,"创建套券-指定限制商品");
		try {
			CreateBagBean createbagBean=setDefaultCreatebagBean();
			 List<String> list = new ArrayList<String>();
            list.add("qaffsfs");
            list.add("qaffsfsewrwer");
            list.add("qaffsfswerwqerqwrqw");
            createbagBean.getBatchInfos().get(0).setProductIds(list);
			createbagCall.setData(createbagBean);
			createbagCall.callService();			
			verifyReturn();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CreateBag_023() {
		Logger.start(true,"创建套券-指定限制买手");
		try {
			CreateBagBean createbagBean=setDefaultCreatebagBean();
			 List<Integer> list = new ArrayList<Integer>();
			 list.add(Integer.parseInt(EnvSetup.getData("BuyUserId")));
            createbagBean.getBatchInfos().get(0).setSellerIds(list);
			createbagCall.setData(createbagBean);
			createbagCall.callService();			
			verifyReturn();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CreateBag_024() {
		Logger.start(true,"创建套券-指定限制活动");
		try {
			CreateBagBean createbagBean=setDefaultCreatebagBean();
			 List<Integer> list = new ArrayList<Integer>();
			 list.add(1234);
            createbagBean.getBatchInfos().get(0).setActivityIds(list);
			createbagCall.setData(createbagBean);
			createbagCall.callService();			
			verifyReturn();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CreateBag_025() {
		Logger.start(true,"创建套券-指定限制品牌");
		try {
			CreateBagBean createbagBean=setDefaultCreatebagBean();
			 List<Integer> list = new ArrayList<Integer>();
			 list.add(1234);
            createbagBean.getBatchInfos().get(0).setBrands(list);
			createbagCall.setData(createbagBean);
			createbagCall.callService();			
			verifyReturn();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CreateBag_026() {
		Logger.start(true,"创建套券-指定限制分类");
		try {
			CreateBagBean createbagBean=setDefaultCreatebagBean();
			 List<Integer> list = new ArrayList<Integer>();
			 list.add(1234);
            createbagBean.getBatchInfos().get(0).setCategories(list);
			createbagCall.setData(createbagBean);
			createbagCall.callService();			
			verifyReturn();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CreateBag_027() {
		Logger.start(true,"创建套券-指定限制国家");
		try {
			CreateBagBean createbagBean=setDefaultCreatebagBean();
			 List<Integer> list = new ArrayList<Integer>();
			 list.add(1234);
            createbagBean.getBatchInfos().get(0).setCountrys(list);
			createbagCall.setData(createbagBean);
			createbagCall.callService();			
			verifyReturn();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CreateBag_028() {
		Logger.start(true,"创建套券-指定限制国家和分类");
		try {
			CreateBagBean createbagBean=setDefaultCreatebagBean();
			List<Integer> countrylist = new ArrayList<Integer>();
            countrylist.add(100);
            countrylist.add(101);
            List<Integer> Categorieslist = new ArrayList<Integer>();
            Categorieslist.add(1);
            Categorieslist.add(2);
            
            createbagBean.getBatchInfos().get(0).setCountrys(countrylist);
            createbagBean.getBatchInfos().get(0).setCategories(Categorieslist);
			createbagCall.setData(createbagBean);
			createbagCall.callService();			
			verifyReturn();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CreateBag_029() {
		Logger.start(true,"创建套券-CouponBatch验证-优惠卷生成总数不能小于0");
		try {
			setDefaultCreatebagBean();
			createbagBean.setTotalNum(-1);
			createbagCall.setData(createbagBean);
			createbagCall.callService();			
		    Logger.verifyEquals(true,
                    createbagCall.getMessage().contains("套券生成总数不能小于0"),
                    "验证返回Message值:套券生成总数不能小于0");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CreateBag_030() {
		Logger.start(true,"创建套券-CouponBatch验证-单用户使用最大次数不能小于0");
		try {
			setDefaultCreatebagBean();
			createbagBean.setReceiveTimesPerUser(-1);
			createbagCall.setData(createbagBean);
			createbagCall.callService();			
		    Logger.verifyEquals(true,
                    createbagCall.getMessage().contains("receiveTimesPerUser:每个用户领取的最大次数必须大于0"),
                    "验证返回Message值:receiveTimesPerUser:每个用户领取的最大次数必须大于0");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CreateBag_031() {
		Logger.start(true,"创建套券-CouponBatch验证-CouponBatch验证-必须提供创建者ID");
		try {
			setDefaultCreatebagBean();
			createbagBean.setOperatorId(0);
			createbagCall.setData(createbagBean);
			createbagCall.callService();			
		    Logger.verifyEquals(true,
                    createbagCall.getMessage().contains("必须提供创建者ID"),
                    "验证返回Message值:必须提供创建者ID");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CreateBag_032() {
		Logger.start(true,"创建套券-CouponBatch验证-CouponBatch验证-平台创建优惠卷必须提供预备金");
		try {
			setDefaultCreatebagBean();
			createbagBean.setImpresetInvoiceId(null);
			createbagCall.setData(createbagBean);
			createbagCall.callService();			
	          Logger.verifyEquals(true,
	                    createbagCall.getMessage().contains("impresetInvoiceId:平台创建套券必须提供预备金"),
	                    "验证返回Message值为：impresetInvoiceId:平台创建套券必须提供预备金");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
    @Category(P1.class)
    @TestCase
    public void Tc_CreateBag_033() {
        Logger.start(false, "反例-创建套券-CouponBatch验证-平台创建优惠卷必须提供申请部门");
        try {

        	setDefaultCreatebagBean();
			createbagBean.setApplyDepartment(0);
			createbagCall.setData(createbagBean);
			createbagCall.callService();			
	          Logger.verifyEquals(true,
	                    createbagCall.getMessage().contains("applyDepartment:平台创建套券必须提供申请部门"),
	                    "验证返回Message值为：applyDepartment:平台创建套券必须提供申请部门");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }
	
	@Test
    @Category(P1.class)
    @TestCase
    public void Tc_CreateBag_034() {
        Logger.start(false, "反例-创建套券-EffectiveType验证-有效期类型错误");
        try {

        	setDefaultCreatebagBean();
			createbagBean.setEffectiveType(5);
			createbagCall.setData(createbagBean);
			createbagCall.callService();			
	          Logger.verifyEquals(true,
	                    createbagCall.getMessage().contains("effectiveType:有效期类型错误"),
	                    "验证返回Message值为：effectiveType:有效期类型错误");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }
	
	@Test
    @Category(P1.class)
    @TestCase
    public void Tc_CreateBag_035() {
        Logger.start(false, "反例-创建套券-EffectiveType验证-相对有效期生效方式错误");
        try {

        	setDefaultCreatebagBean();
			createbagBean.setEffectiveValidType(5);
			createbagCall.setData(createbagBean);
			createbagCall.callService();			
	          Logger.verifyEquals(true,
	                    createbagCall.getMessage().contains("effectiveValidType:相对有效期生效方式错误"),
	                    "验证返回Message值为：effectiveValidType:相对有效期生效方式错误");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }
	
	@Test
    @Category(P1.class)
    @TestCase
    public void Tc_CreateBag_036() {
        Logger.start(false, "反例-创建套券-EffectiveType验证-相对有效期有效天数必须大于0");
        try {

        	setDefaultCreatebagBean();
			createbagBean.setEffectiveType(1);
			createbagBean.setEffectiveDays(0);
			createbagCall.setData(createbagBean);
			createbagCall.callService();			
	          Logger.verifyEquals(true,
	                    createbagCall.getMessage().contains("相对有效期有效天数必须大于0"),
	                    "验证返回Message值为：相对有效期有效天数必须大于0");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }
	
	@Test
    @Category(P1.class)
    @TestCase
    public void Tc_CreateBag_037() {
        Logger.start(false, "反例-创建套券-绝对有效期错误-ValidEnd < ValidStart");
        try {
        	 Date dNow = new Date(); // 当前时间
             Date dBefore = new Date();
             Date dAfter = new Date();

             Calendar calendar1 = Calendar.getInstance(); // 得到日历
             calendar1.setTime(dNow);// 把当前时间赋给日历
             calendar1.add(Calendar.DAY_OF_MONTH, -1); // 设置为前一天
             dBefore = calendar1.getTime(); // 得到前一天的时间

             Calendar calendar2 = Calendar.getInstance(); // 得到日历
             calendar2.setTime(dNow);// 把当前时间赋给日历
             calendar2.add(Calendar.DAY_OF_MONTH, 10); // 设置为后十天
             dAfter = calendar2.getTime(); // 得到前一天的时间
             
        	setDefaultCreatebagBean();
			createbagBean.setEffectiveType(0);
			createbagBean.setValidStart(dAfter);
			createbagBean.setValidEnd(dBefore);
			createbagCall.setData(createbagBean);
			createbagCall.callService();			
	          Logger.verifyEquals(false,
	                    createbagCall.getMessage().contains("绝对有效期错误"),
	                    "验证返回Message值为：绝对有效期错误");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }
	
	@Test
    @Category(P1.class)
    @TestCase
    public void Tc_CreateBag_038() {
        Logger.start(false, "反例-创建套券-绝对有效期错误-ValidEnd < DateTime.Now");
        try {
        	 Date dNow = new Date(); // 当前时间
             Date dBefore = new Date();
             Date dAfter = new Date();

             Calendar calendar1 = Calendar.getInstance(); // 得到日历
             calendar1.setTime(dNow);// 把当前时间赋给日历
             calendar1.add(Calendar.DAY_OF_MONTH, -1); // 设置为前一天
             dBefore = calendar1.getTime(); // 得到前一天的时间

             Calendar calendar2 = Calendar.getInstance(); // 得到日历
             calendar2.setTime(dNow);// 把当前时间赋给日历
             calendar2.add(Calendar.DAY_OF_MONTH, 10); // 设置为后十天
             dAfter = calendar2.getTime(); // 得到前一天的时间
             
        	setDefaultCreatebagBean();
			createbagBean.setEffectiveType(0);
			createbagBean.setValidEnd(dBefore);
			
			createbagCall.setData(createbagBean);
			createbagCall.callService();			
	          Logger.verifyEquals(false,
	                    createbagCall.getMessage().contains("绝对有效期错误"),
	                    "验证返回Message值为：绝对有效期错误");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }
	
	@Test
    @Category(P1.class)
    @TestCase
    public void Tc_CreateBag_039() {
        Logger.start(false, "反例-创建套券-必须提供申请人-null");
        try {
        	setDefaultCreatebagBean();
			createbagBean.setApplyUser(null);
			
			createbagCall.setData(createbagBean);
			createbagCall.callService();			
	          Logger.verifyEquals(true,
	                    createbagCall.getMessage().contains("applyUser:必须提供申请人"),
	                    "验证返回Message值为：applyUser:必须提供申请人");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }
	
	@Test
    @Category(P1.class)
    @TestCase
    public void Tc_CreateBag_040() {
        Logger.start(false, "反例-创建套券-必须提供申请人-空字符");
        try {
        	setDefaultCreatebagBean();
			createbagBean.setApplyUser("");
			
			createbagCall.setData(createbagBean);
			createbagCall.callService();			
	          Logger.verifyEquals(true,
	                    createbagCall.getMessage().contains("applyUser:必须提供申请人"),
	                    "验证返回Message值为：applyUser:必须提供申请人");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }
	@Test
    @Category(P1.class)
    @TestCase
    public void Tc_CreateBag_041() {
        Logger.start(false, "反例-创建套券-必须提供申请理由-null");
        try {
        	setDefaultCreatebagBean();
			createbagBean.setApplyMemo(null);
			
			createbagCall.setData(createbagBean);
			createbagCall.callService();			
	          Logger.verifyEquals(true,
	                    createbagCall.getMessage().contains("applyMemo:必须提供套券说明"),
	                    "验证返回Message值为：applyMemo:必须提供套券说明");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }
	
	@Test
    @Category(P1.class)
    @TestCase
    public void Tc_CreateBag_042() {
        Logger.start(false, "反例-创建套券-必须提供申请理由-空字符");
        try {
        	setDefaultCreatebagBean();
			createbagBean.setApplyMemo("");
			
			createbagCall.setData(createbagBean);
			createbagCall.callService();			
	          Logger.verifyEquals(true,
	                    createbagCall.getMessage().contains("applyMemo:必须提供套券说明"),
	                    "验证返回Message值为：applyMemo:必须提供套券说明");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }
	@Test
    @Category(P1.class)
    @TestCase
    public void Tc_CreateBag_043() {
        Logger.start(false, "反例-创建套券-用户类型错误");
        try {
        	setDefaultCreatebagBean();
			createbagBean.setReceiveUserType(9);
			
			createbagCall.setData(createbagBean);
			createbagCall.callService();			
	          Logger.verifyEquals(true,
	                    createbagCall.getMessage().contains("receiveUserType:用户类型错误"),
	                    "验证返回Message值为：receiveUserType:用户类型错误");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }
	@Test
    @Category(P1.class)
    @TestCase
    public void Tc_CreateBag_044() {
        Logger.start(false, "反例-创建套券-未提供优惠卷面额-values == null");
        try {
        	setDefaultCreatebagBean();
        	createbagBean.getBatchInfos().get(0).setDeductionMaxAmount(null);
			
			createbagCall.setData(createbagBean);
			createbagCall.callService();			
	          Logger.verifyEquals(true,
	                    createbagCall.getMessage().contains("能够抵扣的金额必须大于0"),
	                    "验证返回Message值为：能够抵扣的金额必须大于0");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }
	@Test
    @Category(P1.class)
    @TestCase
    public void Tc_CreateBag_045() {
        Logger.start(false, "反例-创建套券-未提供优惠卷面额-values == 0");
        try {
        	setDefaultCreatebagBean();
        	createbagBean.getBatchInfos().get(0).setDeductionMaxAmount(new BigDecimal(0));
			
			createbagCall.setData(createbagBean);
			createbagCall.callService();			
	          Logger.verifyEquals(true,
	                    createbagCall.getMessage().contains("能够抵扣的金额必须大于0"),
	                    "验证返回Message值为：能够抵扣的金额必须大于0");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }
	@Test
    @Category(P1.class)
    @TestCase
    public void Tc_CreateBag_046() {
        Logger.start(false, "反例-创建套券-能够抵扣的金额必须大于0");
        try {
        	setDefaultCreatebagBean();
        	createbagBean.getBatchInfos().get(0).setOrderMinAmount(new BigDecimal(-1));
			
			createbagCall.setData(createbagBean);
			createbagCall.callService();			
	          Logger.verifyEquals(true,
	                    createbagCall.getMessage().contains("订单满多少金额必须大于0"),
	                    "验证返回Message值为：订单满多少金额必须大于0");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }
	@Test
    @Category(P1.class)
    @TestCase
    public void Tc_CreateBag_047() {
        Logger.start(false, "反例-创建套券-订单满多少金额必须大于0");
        try {
        	setDefaultCreatebagBean();
        	createbagBean.getBatchInfos().get(0).setOrderMinAmount(new BigDecimal(0));
        	createbagBean.getBatchInfos().get(0).setDeductionMaxAmount(new BigDecimal(10));
			
			createbagCall.setData(createbagBean);
			createbagCall.callService();			
	          Logger.verifyEquals(true,
	                    createbagCall.getMessage().contains("订单满多少金额必须大于0"),
	                    "验证返回Message值为：订单满多少金额必须大于0");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }
	
	@Test
    @Category(P1.class)
    @TestCase
    public void Tc_CreateBag_048() {
        Logger.start(false, "反例-创建套券-订单满足金额必须大于可以抵扣的金额");
        try {
        	setDefaultCreatebagBean();
        	createbagBean.getBatchInfos().get(0).setOrderMinAmount(new BigDecimal(10));
        	createbagBean.getBatchInfos().get(0).setDeductionMaxAmount(new BigDecimal(20));
			
			createbagCall.setData(createbagBean);
			createbagCall.callService();			
	          Logger.verifyEquals(true,
	                    createbagCall.getMessage().contains("订单满足金额必须大于可以抵扣的金额"),
	                    "验证返回Message值为：订单满足金额必须大于可以抵扣的金额");
        } catch (Exception e) {
            Logger.fail(e);
        }
    }
	
	@Test
    @Category(P1.class)
    @TestCase
    public void Tc_CreateBag_049() {
        Logger.start(false, "反例-创建套券-用户类型错误");
        try {
        	setDefaultCreatebagBean();
        	createbagBean.setReceiveUserType(5);
			
			createbagCall.setData(createbagBean);
			createbagCall.callService();			
	          Logger.verifyEquals(true,
	                    createbagCall.getMessage().contains("用户类型错误"),
	                    "验证返回Message值为：用户类型错误");
        } catch (Exception e) {
            Logger.fail(e);
        }
    }
	
	@Test
    @Category(P1.class)
    @TestCase
    public void Tc_CreateBag_050() {
        Logger.start(false, "反例-创建套券-获取优惠券无效");
        try {
        	setDefaultCreatebagBean();
        	createbagBean.setAcquireMethod(5);
			
			createbagCall.setData(createbagBean);
			createbagCall.callService();			
	          Logger.verifyEquals(true,
	                    createbagCall.getMessage().contains("优惠券获取方式错误"),
	                    "验证返回Message值为：优惠券获取方式错误");
        } catch (Exception e) {
            Logger.fail(e);
        }
    }
	@Test
    @Category(P1.class)
    @TestCase
    public void Tc_CreateBag_051() {
        Logger.start(false, "正例-创建套券-获取优惠券为兑换");
        try {
        	setDefaultCreatebagBean();
        	createbagBean.setAcquireMethod(2);
			
			createbagCall.setData(createbagBean);
			createbagCall.callService();			
			verifyReturn();
        } catch (Exception e) {
            Logger.fail(e);
        }
    }
	
	
	@Test
    @Category(P1.class)
    @TestCase
    public void Tc_CreateBag_052() {
        Logger.start(false, "正例-创建套券-指定活动");
        try {
        	setDefaultCreatebagBean();
            List<Integer> list = new ArrayList<Integer>();
            list.add(1234);
            createbagBean.getBatchInfos().get(0).setActivityIds(list);
			createbagCall.setData(createbagBean);
			createbagCall.callService();			
			verifyReturn();
        } catch (Exception e) {
            Logger.fail(e);
        }
    }
	
	@Test
    @Category(P1.class)
    @TestCase
    public void Tc_CreateBag_053() {
        Logger.start(false, "正例-创建套券-指定活动+品牌");
        try {
        	setDefaultCreatebagBean();
            List<Integer> list = new ArrayList<Integer>();
            list.add(1234);
            createbagBean.getBatchInfos().get(0).setActivityIds(list);
            
            
            List<Integer> list2 = new ArrayList<Integer>();
            list2.add(1234);
            createbagBean.getBatchInfos().get(0).setBrands(list2);
            
			createbagCall.setData(createbagBean);
			createbagCall.callService();			
			Logger.verifyEquals("0", createbagCall.getCode(), "验证返回code");
	        Logger.verifyEquals("操作成功！", createbagCall.getMessage(),
	                "验证返回Message");
	        Logger.verifyEquals(false, createbagCall.getbagCode().isEmpty(),
	                "验证返回BatchCode非空");

	        String bagCode = createbagCall.getbagCode();

	        // 验证表CouponBatch表
	        checkcouponbag(bagCode);
	        List<couponbatch> couponbatchs = checkcouponbatch(bagCode);
	        for(couponbatch couponbatch:couponbatchs)
	        {
		        checkcouponSequence( couponbatch);
		        
		        List<BatchInfo> infos= createbagBean.getBatchInfos();
		        for(int i=0;i<infos.size();i++){
		        List<couponusecondition> cslist=new couponuseconditionWapper().selectByConditionTypeAndBatchId(couponbatch.getBatchId(),3);
		             Logger.verifyEquals(cslist.size(), infos.get(i).getActivityIds().size(), "验证活动返回数据库couponusecondition表条数与传入的一直");
		    			int count=0;
		 			for(int j=0;j<cslist.size();j++){
		 				count++;
		     			Logger.verifyEquals(infos.get(i).getActivityIds().get(j).toString(), cslist.get(j).getConditionValue(),
		                       "验证限制类型为指定活动时 数据库couponusecondition表中第"+count+"个ConditionValue");
		     			Logger.verifyEquals(3, cslist.get(j).getConditionType(),
		                         "验证限制类型为指定活动时 数据库couponusecondition表中第"+count+"个ConditionValue");
		     		    Logger.verifyEquals(true, infos.get(i).getActivityIds().contains(Integer.parseInt(cslist.get(j).getConditionValue().toString())),
		                         "验证限制类型为指定活动时 数据库couponbatch表中UseConditionType=3");
		 			}

		 		  List<couponusecondition> brandlist=new couponuseconditionWapper().selectByConditionTypeAndBatchId(couponbatch.getBatchId(),6);
		           Logger.verifyEquals(brandlist.size(), infos.get(i).getBrands().size(), "验证品牌返回数据库couponusecondition表条数与传入的一直");
		    			int count1=0;
		 			for(int j=0;j<brandlist.size();j++){
		 				count1++;
		     			Logger.verifyEquals(infos.get(i).getBrands().get(j).toString(), brandlist.get(j).getConditionValue(),
		                       "验证限制类型为指定品牌时 数据库couponusecondition表中第"+count1+"个ConditionValue");
		     			Logger.verifyEquals(6, brandlist.get(j).getConditionType(),
		                         "验证限制类型为指定品牌时 数据库couponusecondition表中第"+count1+"个ConditionValue");
		     		    Logger.verifyEquals(true, infos.get(i).getBrands().contains(Integer.parseInt(brandlist.get(j).getConditionValue())),
		                         "验证限制类型为指定品牌时 数据库couponbatch表中第"+count1+"个UseConditionType=10");
				}
	        }
	    }
        } catch (Exception e) {
            Logger.fail(e);
        }
    }
	 private void verifyReturn() throws InterruptedException {

	        Logger.verifyEquals("0", createbagCall.getCode(), "验证返回code");
	        Logger.verifyEquals("操作成功！", createbagCall.getMessage(),
	                "验证返回Message");
	        Logger.verifyEquals(false, createbagCall.getbagCode().isEmpty(),
	                "验证返回BatchCode非空");

	        String bagCode = createbagCall.getbagCode();

	        // 验证表CouponBatch表
	        checkcouponbag(bagCode);
	        List<couponbatch> couponbatchs = checkcouponbatch(bagCode);
	        for(couponbatch couponbatch:couponbatchs)
	        {
		       // checkcouponbatchext(couponbatch.getBatchId());
		        checkcouponusecondition(couponbatch.getBatchId());
		        checkcouponSequence( couponbatch);
	        }
	    }
   private String checkcouponbag(String bagCode)
   {
	   Logger.comment("====方法：验证数据库CouponBag====");
	   couponbag bag=new couponbagWapper().selectByPrimaryKey(bagCode);
       Logger.verifyEquals(createbagBean.getName(),bag.getName(),
               "验证数据库CouponBag表中Name");
       Logger.verifyEquals(createbagBean.getDescription(),bag.getDescription(),
               "验证数据库CouponBag表中Description");
       Logger.verifyEquals(createbagBean.getOperatorId(),bag.getOperatorId(),
               "验证数据库CouponBag表中OperatorId");
       Logger.verifyEquals(createbagBean.getApplyUser(),bag.getApplyUser(),
               "验证数据库CouponBag表中ApplyUser");
       Logger.verifyEquals(createbagBean.getApplyMemo(),bag.getApplyMemo(),
               "验证数据库CouponBag表中ApplyMemo");
       Logger.verifyEquals(createbagBean.getTotalNum(),bag.getTotalNum(),
               "验证数据库CouponBag表中TotalNum");
       Logger.verifyEquals(0,bag.getReceivedCount(),
               "验证数据库CouponBag表中ReceivedCount");
       Logger.verifyEquals(createbagBean.getAcquireStartTime().toString(),bag.getAcquireStartTime().toString(),
               "验证数据库CouponBag表中AcquireStartTime");
       Logger.verifyEquals(createbagBean.getAcquireEndTime().toString(),bag.getAcquireEndTime().toString(),
               "验证数据库CouponBag表中AcquireEndTime");
       Logger.verifyEquals(createbagBean.getAcquireMethod(),bag.getAcquireMethod(),
               "验证数据库CouponBag表中AcquireMethod");
       Logger.verifyEquals(createbagBean.getReceiveTimesPerUser(),bag.getReceiveTimesPerUser(),
               "验证数据库CouponBag表中ReceiveTimesPerUser");
       Logger.verifyEquals(createbagBean.getEffectiveType(),bag.getEffectiveType(),
               "验证数据库CouponBag表中EffectiveType");
       Logger.verifyEquals(createbagBean.getEffectiveValidType(),bag.getEffectiveValidType(),
               "验证数据库CouponBag表中EffectiveValidType");
       Logger.verifyEquals(createbagBean.getEffectiveDays(),bag.getEffectiveDays(),
               "验证数据库CouponBag表中EffectiveDays");
       Logger.verifyEquals(createbagBean.getValidStart().toString(),bag.getValidStart().toString(),
               "验证数据库CouponBag表中ValidStart");
       
       Logger.verifyEquals(createbagBean.getValidEnd().toString(),bag.getValidEnd().toString(),
               "验证数据库CouponBag表中ValidEnd");
       Logger.verifyEquals(createbagBean.getReceiveUserType(),bag.getReceiveUserType(),
               "验证数据库CouponBag表中ReceiveUserType");
//       Logger.verifyEquals(createbagBean.getUsePlatformI ds(),bag.getUsePlatformIds(),
//               "验证数据库CouponBag表中UsePlatformIds");
       if(createbagBean.getUsePlatformIds().size()>0)
       {
      	 String str="";
      	 for(int i=0;i<createbagBean.getUsePlatformIds().size();i++)
      	 {
      		 str+=createbagBean.getUsePlatformIds().get(i)+",";
      	 }
          	Logger.verifyEquals(str.substring(0, str.length()-1), bag.getUsePlatformIds(),
                      "验证数据库CouponBatch表中UsePlatformIds");
       }else
       {
       	Logger.verifyEquals("", bag.getUsePlatformIds(),
                  "验证数据库CouponBatch表中UsePlatformIds");
       }
       Logger.verifyEquals(createbagBean.getTotalNum(),bag.getTotalNum(),
               "验证数据库CouponBag表中TotalNum");
       Logger.verifyEquals(createbagBean.getImpresetInvoiceId(),bag.getImpresetInvoiceId(),
               "验证数据库CouponBag表中ImpresetInvoiceId");
       Logger.verifyEquals(createbagBean.getApplyDepartment(),bag.getApplyDepartment(),
               "验证数据库CouponBag表中ApplyDepartment");
       Logger.verifyEquals(false,bag.getIsInvalid(),
               "验证数据库CouponBag表中IsInvalid");
       Logger.verifyEquals("",bag.getInvalidUser(),
               "验证数据库CouponBag表中InvalidUser");
       Logger.verifyEquals(null,bag.getInvalidTime(),
               "验证数据库CouponBag表中InvalidTime");
       return bag.getBagCode();
     
   }
   private List<couponbatch> checkcouponbatch(String batchCode) {
       Logger.comment("====方法：验证数据库CouponBatch====");
       List<couponbatch> couponbatchs = new couponbatchWapper()
               .getCouponBatchByBagCode(batchCode);

       Logger.verifyEquals(true, couponbatchs.size()>0,
               "验证CouponBatch表生成BatchCode=" + batchCode + "的条数。");

       if (couponbatchs.size() >= 1) {
       for(int k=0;k<couponbatchs.size();k++){
       	 couponbatch batchItem = couponbatchs.get(k);
        	 couponbatchext couponbatchext=new couponbatchextWapper().selectByPrimaryKey(batchItem.getBatchId());

            Logger.verifyEquals(createbagBean.getApplyDepartment(),couponbatchext.getApplyDepartment(),
                    "验证数据库CouponBatch表中ApplyDepartment");
            // 平台创建
          //  CouponValue couponValue = createbagBean.getBatchInfos().get(0);
            List<BatchInfo> infos= createbagBean.getBatchInfos();
            for(int i=0;i<infos.size();i++){
                Logger.verifyEquals(infos.get(i).getOrderMinAmount().stripTrailingZeros(), batchItem.getMinOrderValue().stripTrailingZeros(),
                        "验证数据库CouponBatch表中MinOrderValue");
                Logger.verifyEquals(infos.get(i).getDeductionMaxAmount().stripTrailingZeros(), batchItem.getCouponValue().stripTrailingZeros(),
                        "验证数据库CouponBatch表中CouponValue");
                Logger.verifyEquals(1, batchItem.getCreaterType().intValue(),
                        "验证数据库CouponBatch表中CreaterType");
                Logger.verifyEquals(infos.get(i).getCouponName(),
                        batchItem.getCouponName(),
                        "验证数据库CouponBatch表中CouponName");
                Logger.verifyEquals(createbagBean.getReceiveTimesPerUser(),
                        batchItem.getReceiveTimesPerUser(),
                        "验证数据库CouponBatch表中ReceiveTimesPerUser");
                Logger.verifyEquals(createbagBean.getTotalNum(),
                        batchItem.getTotalNum(),
                        "验证数据库CouponBatch表中TotalNum");


                Logger.verifyEquals(createbagBean.getImpresetInvoiceId(),
                  		 couponbatchext.getImpresetInvoiceId(),
                           "验证数据库CouponBatch表中impresetInvoiceId");

                   Logger.verifyEquals(false, batchItem.getIsInvalid(),
                           "验证数据库CouponBatch表中IsInvalid");
                   
                   Logger.verifyEquals(false, batchItem.getIsShowInPage(),
                           "验证数据库CouponBatch表中IsShowInPage");

                   Logger.verifyEquals("", couponbatchext.getInvalidUser(),
                           "验证数据库CouponBatch表中InvalidUser");
                   Logger.verifyEquals(infos.get(i).getApplyMemo(), couponbatchext.getApplyMemo(),
                           "验证数据库CouponBatch表中ApplyMemo");
                   Logger.verifyEquals(createbagBean.getApplyUser(), couponbatchext.getApplyUser(),
                           "验证数据库CouponBatch表中ApplyUser");

                   Logger.verifyEquals(createbagBean.getOperatorId(),
                           batchItem.getOperatorId(),
                           "验证数据库CouponBatch表中OperatorId");

                   
                   // 新加字段
                   Logger.verifyEquals(infos.get(i).getCouponDes(), batchItem.getCouponDes(),
                           "验证数据库CouponBatch表中CouponDes");

                   if(createbagBean.getAcquireStartTime()!=null)
                   {
                   	Logger.verifyEquals(createbagBean.getAcquireStartTime().toString(), batchItem.getAcquireStartTime().toString(),
                               "验证数据库CouponBatch表中AcquireStartTime");
                   }
                   
                   if(createbagBean.getAcquireEndTime()!=null)
                   {
                   	Logger.verifyEquals(createbagBean.getAcquireEndTime().toString(), batchItem.getAcquireEndTime().toString(),
                               "验证数据库CouponBatch表中AcquireEndTime");
                   }
                   
                   if(createbagBean.getAcquireMethod()!=0)
                   {
                   	Logger.verifyEquals(createbagBean.getAcquireMethod(), batchItem.getAcquireMethod().intValue(),
                               "验证数据库CouponBatch表中AcquireCouponMethod");
                   }
                   if(createbagBean.getUsePlatformIds().size()>0)
                   {
                  	 String str="";
                  	 for(int j=0;j<createbagBean.getUsePlatformIds().size();j++)
                  	 {
                  		 str+=createbagBean.getUsePlatformIds().get(j)+",";
                  	 }
                      	Logger.verifyEquals(str.substring(0, str.length()-1), batchItem.getUsePlatformIds(),
                                  "验证数据库CouponBatch表中UsePlatformIds");
                      	
                   }else
                   {
                   	Logger.verifyEquals("", batchItem.getUsePlatformIds(),
                              "验证数据库CouponBatch表中UsePlatformIds");
                   }
                   Logger.comment("====方法：验证数据库checkcouponbatchext====");
                   // couponbatchext couponbatchext=new couponbatchextWapper().selectByPrimaryKey(batchId);
                    Logger.verifyEquals(createbagBean.getImpresetInvoiceId(), couponbatchext.getImpresetInvoiceId(),
                            "验证数据库couponbatchext表中ImpresetInvoiceId");
                    Logger.verifyEquals(createbagBean.getApplyDepartment(), couponbatchext.getApplyDepartment(),
                            "验证数据库couponbatchext表中ApplyDepartment");
                    Logger.verifyEquals(createbagBean.getApplyUser(), couponbatchext.getApplyUser(),
                            "验证数据库couponbatchext表中ApplyUser");
                    Logger.verifyEquals(infos.get(i).getApplyMemo(), couponbatchext.getApplyMemo(),
                            "验证数据库couponbatchext表中ApplyMemo");
            }
       }
       }
       return couponbatchs;
   }
   private void checkcouponusecondition(int batchId)
   {
   	 Logger.comment("====方法：验证数据库checkcouponusecondition====");
     //0:通用 1:指定买手，2：指定商品，3：指定活动，4：指定分类，5：指定国家，6：指定品牌，7：指定国家和分类，8：仅优先商品
   	//国家和分类
    List<BatchInfo> infos= createbagBean.getBatchInfos();
    for(int i=0;i<infos.size();i++){
    	
       	List<couponusecondition> couponuseconditions=new couponuseconditionWapper().selectByBatchId(batchId);
       	couponbatch couponbatch= new couponbatchWapper().selectByPrimaryKey(batchId);
       	
    	if(couponuseconditions.size()==0)
       	{
    			Logger.verifyEquals(0, couponbatch.getUseConditionType(),
                       "验证限制类型为通用时 数据库couponbatch表中UseConditionType=0");
       	}
		if(infos.get(i).getCountrys().size()>0 && infos.get(i).getCategories().size()>0)
		{
		    Logger.verifyEquals(7, couponbatch.getUseConditionType(),
                   "验证限制类型为指定国家和分类时 数据库couponbatch表中UseConditionType=7");
		}
		if(infos.get(i).getSellerIds().size()>0)
		{
			List<couponusecondition> cslist=new couponuseconditionWapper().selectByConditionTypeAndBatchId(batchId,1);
			int count=0;
			for(int j=0;j<cslist.size();j++){
				count++;
   			Logger.verifyEquals(infos.get(i).getSellerIds().get(j).toString(), cslist.get(j).getConditionValue(),
                     "验证限制类型为指定买手时 数据库couponusecondition表中第"+count+"个ConditionValue");
   			Logger.verifyEquals(1, couponuseconditions.get(j).getConditionType(),
                       "验证限制类型为指定买手时 数据库couponbatch表中UseConditionType=1");
   			Logger.verifyEquals(1, couponbatch.getUseConditionType(),
                       "验证限制类型为指定买手时 数据库couponbatch表中UseConditionType=1");
			}
			return;
		}
		if(infos.get(i).getProductIds().size()>0)
		{
			List<couponusecondition> cslist=new couponuseconditionWapper().selectByConditionTypeAndBatchId(batchId,2);
  			int count=0;
			for(int j=0;j<cslist.size();j++){
				count++;
   			Logger.verifyEquals(infos.get(i).getProductIds().get(j).toString(), cslist.get(j).getConditionValue(),
                     "验证限制类型为指定商品时 数据库couponusecondition表中第"+count+"个ConditionValue");
   		   Logger.verifyEquals(2, couponuseconditions.get(j).getConditionType(),
                       "验证限制类型为指定买手时 数据库couponbatch表中UseConditionType=2");
			   Logger.verifyEquals(2, couponbatch.getUseConditionType(),
                   "验证限制类型为指定商品时 数据库couponbatch表中UseConditionType=2");
			}
			return;
		}
		if(infos.get(i).getActivityIds().size()>0)
		{
			List<couponusecondition> cslist=new couponuseconditionWapper().selectByConditionTypeAndBatchId(batchId,3);
  			int count=0;
			for(int j=0;j<cslist.size();j++){
				count++;
   			Logger.verifyEquals(infos.get(i).getActivityIds().get(j).toString(), cslist.get(j).getConditionValue(),
                     "验证限制类型为指定活动时 数据库couponusecondition表中第"+count+"个ConditionValue");
   		    Logger.verifyEquals(3, couponuseconditions.get(j).getConditionType(),
                       "验证限制类型为指定活动时 数据库couponbatch表中UseConditionType=3");
			   Logger.verifyEquals(3, couponbatch.getUseConditionType(),
                   "验证限制类型为指定活动时 数据库couponbatch表中UseConditionType=3");
			}
			return;
		}
		if(infos.get(i).getCategories().size()>0)
		{
			List<couponusecondition> cslist=new couponuseconditionWapper().selectByConditionTypeAndBatchId(batchId,4);
  			int count=0;
			for(int j=0;j<cslist.size();j++){
				count++;
   			Logger.verifyEquals(infos.get(i).getCategories().get(j).toString(), cslist.get(j).getConditionValue(),
                     "验证限制类型为指定分类时 数据库couponusecondition表中第"+count+"个ConditionValue");
   		    Logger.verifyEquals(4, couponuseconditions.get(j).getConditionType(),
                       "验证限制类型为指定分类时 数据库couponbatch表中UseConditionType=4");
   		    if(infos.get(i).getCountrys().size()==0)
			     Logger.verifyEquals(4, couponbatch.getUseConditionType(),
                    "验证限制类型为指定分类时 数据库couponbatch表中UseConditionType=4");
			}
			return;
		}
		if(infos.get(i).getCountrys().size()>0)
		{
			List<couponusecondition> cslist=new couponuseconditionWapper().selectByConditionTypeAndBatchId(batchId,5);
  			int count=0;
			for(int j=0;j<cslist.size();j++){
				count++;
   			Logger.verifyEquals(infos.get(i).getCountrys().get(j).toString(), cslist.get(j).getConditionValue(),
                     "验证限制类型为指定国家时 数据库couponusecondition表中第"+count+"个ConditionValue");
   		    Logger.verifyEquals(5, couponuseconditions.get(j).getConditionType(),
                       "验证限制类型为指定国家时 数据库couponbatch表中UseConditionType=5");
   		    if(infos.get(i).getCategories().size()==0)
			   Logger.verifyEquals(5, couponbatch.getUseConditionType(),
                   "验证限制类型为指定国家时 数据库couponbatch表中UseConditionType=5");
			}
			return;
		}
		//品牌
		if(infos.get(i).getBrands().size()>0)
		{
			List<couponusecondition> cslist=new couponuseconditionWapper().selectByConditionTypeAndBatchId(batchId,6);
  			int count=0;
		  for(int j=0;j<cslist.size();j++){
				count++;
   			Logger.verifyEquals(infos.get(i).getBrands().get(j).toString(), cslist.get(j).getConditionValue(),
                     "验证限制类型为指定品牌时 数据库couponusecondition表中第"+count+"个ConditionValue");
   		    Logger.verifyEquals(6, couponuseconditions.get(j).getConditionType(),
                       "验证限制类型为指定品牌时 数据库couponbatch表中UseConditionType=6");
		    	Logger.verifyEquals(6, couponbatch.getUseConditionType(),
                   "验证限制类型为指定品牌时 数据库couponbatch表中UseConditionType=6");
			}
			//优先商品
			if(infos.get(i).getLimitPspProduct()==true)
			{
				Logger.verifyEquals(8, couponbatch.getUseConditionType(),
	                   "验证限制类型为指定优先商品时 数据库couponbatch表中UseConditionType");
				Logger.verifyEquals(8, couponbatch.getUseConditionType(),
	                   "验证限制类型为优选商品时 数据库couponbatch表中UseConditionType=8");
				return;
			}
		  return;
		}

    }
   }
	
   private void checkcouponSequence(couponbatch couponbatch )
   {
   	 Logger.comment("====方法：验证数据库checkcouponSequence====");
   	 couponsequence couponSequence=new couponsequenceWapper().selectByPrimaryKey(4);
   	 if(couponbatch.getBatchId()>couponSequence.getSequenceCount())
   	 {	
   		 Logger.verifyEquals(true, couponSequence.getSequenceCount()-couponbatch.getBatchId()<200,
                    "验证 数据库couponbatch表的主键batchId大于couponSequence序列基数时，序列加200");
   	 }
   	 
   }
	
	private CreateBagBean setDefaultCreatebagBean()
	{
		createbagBean.setName("自动化创建套券领取优惠券");
		createbagBean.setDescription("自动化测试创建套券领取优惠券描述");
		createbagBean.setOperatorId(222222);
		createbagBean.setApplyUser("自动化user111");
		createbagBean.setApplyMemo("自动化测试创建套券领取优惠券申请理由");
		createbagBean.setEffectiveType(0);
		createbagBean.setEffectiveValidType(0);
		createbagBean.setEffectiveDays(0);
		
		Date dNow = new Date(); // 当前时间
		Date dBefore = new Date();
		Date dAfter = new Date();

		Calendar calendar1 = Calendar.getInstance(); // 得到日历
		calendar1.setTime(dNow);// 把当前时间赋给日历
		calendar1.add(Calendar.DAY_OF_MONTH, -1); // 设置为前一天
		dBefore = calendar1.getTime(); // 得到前一天的时间

		Calendar calendar2 = Calendar.getInstance(); // 得到日历
		calendar2.setTime(dNow);// 把当前时间赋给日历
		calendar2.add(Calendar.DAY_OF_MONTH, 10); // 设置为后十天
		dAfter = calendar2.getTime(); // 得到前一天的时间

		createbagBean.setValidStart(dBefore);
		createbagBean.setValidEnd(dAfter);
		createbagBean.setAcquireStartTime(dBefore);
		createbagBean.setAcquireEndTime(dAfter);
		// 获取优惠券方式(1:领取(默认) 2:兑换)
		createbagBean.setAcquireMethod(1);
		createbagBean.setTotalNum(10);
		createbagBean.setReceiveTimesPerUser(1);
		createbagBean.setReceiveUserType(0);
		List<Integer> usePlatforms = new ArrayList<Integer>();
		/*
		 * usePlatforms.add(1); usePlatforms.add(2); usePlatforms.add(3);
		 */
		createbagBean.setUsePlatformIds(usePlatforms);
		createbagBean.setApplyDepartment(1);
		String impresetInvoiceId = EnvSetup.getData("ImpresetInvoiceId");
		createbagBean.setImpresetInvoiceId(impresetInvoiceId);
		
		List<BatchInfo> BatchInfos=new ArrayList<BatchInfo>();
		BatchInfo info=new BatchInfo();
		info.setCouponName("自动化创建套券优惠券名称-子套券");
		info.setCouponDes("自动化创建套券优惠券描述-子套券");
		info.setApplyMemo("自动化创建申请理由-子套券");
		info.setOrderMinAmount(new BigDecimal(2));
		info.setDeductionMaxAmount(new BigDecimal(1));
		List<String> productIds = new ArrayList<String>();
		info.setProductIds(productIds);
		List<Integer> SellerIds = new ArrayList<Integer>();
		info.setSellerIds(SellerIds);
		List<Integer> ActivityIds = new ArrayList<Integer>();
		info.setActivityIds(ActivityIds);
		List<Integer> Brands = new ArrayList<Integer>();
		info.setBrands(Brands);
		List<Integer> Countrys = new ArrayList<Integer>();
		info.setCountrys(Countrys);
		List<Integer> Categories = new ArrayList<Integer>();
		info.setCategories(Categories);
		info.setLimitPspProduct(false);
		BatchInfos.add(info);
		createbagBean.setBatchInfos(BatchInfos);
		return createbagBean;
	}
}